<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of User
 *
 * @author dejo
 */
class Form_User extends Zend_Form {

    public function __construct() {

        parent::__construct($options);

        $this->setName('user');
        $this->setMethod('post');

        $username = new Zend_Form_Element_Text('username');
        $username->setRequired(true)
                ->addValidators(array(
                    array('StringLength', false, array(5, 50)),
                    array('Db_NoRecordExists', false, array('gebruikers', 'username'))
                    ))
                ->addFilters(array('StripTags', 'StringTrim'))
                ->setLabel('Gebruikersnaam');

        $realname = new Zend_Form_Element_Text('realname');
        $realname->setRequired(true)
                ->addValidators(array(
                    array('StringLength', false, array(5, 50)),
                    ))
                ->addFilters(array('StripTags', 'StringTrim'))
                ->setLabel('Naam gebruiker');

        $password = new Zend_Form_Element_Password('password');
        $password->setRequired(true)
                ->addFilters(array('StripTags', 'StringTrim'))
                ->setLabel('Nieuw wachtwoord');

        $password2 = new Zend_Form_Element_Password('password2');
        $password2->setRequired(true)
                ->addFilters(array('StripTags', 'StringTrim'))
                ->addValidator(new Zend_Validate_Identical($_POST['password']))
                ->setLabel('Bevestig het nieuwe wachtwoord');

        $email = new Zend_Form_Element_Text('email');
        $email->setRequired(true)
                ->addFilters(array('StripTags', 'StringTrim'))
                ->setLabel('E-mailadres')
                ->addValidators(array('EmailAddress'
                    ));

        $role = new Zend_Form_Element_Select('role');
        $role->setLabel('Rol')
                ->setRequired(true)
                ->addMultiOptions(array('guest'=> 'Gast', 'user' => 'Gebruiker', 'admin' => 'Beheerder'));

        $submit = new Zend_Form_Element_Submit('Save');
        $submit->setLabel('Sla op');
        
        $this->addElements(array($username, $realname, $password, $password2, $role, $email, $submit));
        
    }
}
?>
